use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct yata::indicators::TrueStrengthIndex
///
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct TRSI {
    /// 3 signals
    ///Signal #1.
    /// When main value crosses upper zone upwards , returns full sell signal.
    /// When main value crosses lower -zone downwards, returns full buy signal.
    /// Otherwise returns no signal.
    pub signal0: Option<IndicatorActionWrap>,
    /// Signal #2. When main value crosses zero line upwards, returns full buy signal.
    /// When main value crosses zero line downwards, returns full sell signal.
    ///  Otherwise returns no signal.
    pub signal1: Option<IndicatorActionWrap>,
    /// Signal #3. When main value crosses signal line upwards, returns full buy signal.
    /// When main value crosses signal line downwards, returns full sell signal.
    /// Otherwise returns no signal.
    pub signal2: Option<IndicatorActionWrap>,

    /// 2 values
    /// Main value
    /// Range in [-1.0; 1.0]
    pub main: ValueType,

    ///signal line value
    ///Range in [-1.0; 1.0]
    pub signal: ValueType,
}

/// Configuration
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct TRSIConfig {
    ///period1: PeriodType
    ///Long TSI period. Default is 25.
    ///
    ///Range in [period2, PeriodType::MAX).
    pub period1: PeriodType,
    ///period2: PeriodType
    ///Short TSI period. Default is 13.
    ///
    ///Range in (2, period1].    
    pub period2: PeriodType,
    ///period3: PeriodType
    ///Signal line MA period. Default is 13.
    ///
    ///Range in [2, PeriodType::MAX).    
    pub period3: PeriodType,
    ///zone: ValueType
    ///Signal zone size. Default is 0.25.
    ///
    ///Range in [0.0; 1.0]    
    pub zone: ValueType,
    // pub source: Source,
}

impl Default for TRSIConfig {
    fn default() -> Self {
        Self {
            period1: 25,
            period2: 13,
            period3: 13,
            zone: 0.25,
            // source: Source::Close,
        }
    }
}
